package com.jack.vipmis.vip.adv.service;

import java.util.List;

import org.springframework.stereotype.Service;

import com.jack.vipmis.common.entity.search.SearchOperator;
import com.jack.vipmis.common.entity.search.SearchRequest;
import com.jack.vipmis.common.entity.search.Searchable;
import com.jack.vipmis.common.service.BaseService;
import com.jack.vipmis.vip.adv.entity.Advertising;
import com.jack.vipmis.vip.adv.repository.AdvertisingRepository;

/**
 * 
 * @author JackLiang
 * @date 2014-6-18
 * @version 1.0
 */
@Service
public class AdvertisingService extends BaseService<Advertising, Long> {

	private AdvertisingRepository getAdvertisingRepository() {
		return (AdvertisingRepository) baseRepository;
	}

	/**
	 * 
	 * @param type
	 * @return
	 */
	public Advertising findByType(int type) {
		return getAdvertisingRepository().findByType(type);
	}

	public List<Advertising> list(int type) {
		Searchable searchable = SearchRequest.newSearchable();
		searchable.addSearchFilter("type", SearchOperator.eq, type);
		return getAdvertisingRepository().findAll(searchable).getContent();
	}
}
